﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Manager;
using Model;
namespace HealthSystem
{
    public partial class Healthsys_Login : System.Web.UI.Page
    {
        HW_XXX_UserManager manager = new HW_XXX_UserManager();
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {

            HW_XXX_User xxuser= manager.CheckUser(tbxUserName.Text.Trim(), tbxPassword.Text.Trim());
            if (xxuser == null)
            {
                ExtAspNet.Alert.Show("账号或密码错误!");
            }
            else
            {



               ProfileComm profile = (ProfileComm)HttpContext.Current.Profile;


               //profile.AdminUser = new HW_Manger_Admin_User();
               //profile.SchoolUser = new HW_School_User();
               //profile.OrgUser = new HW_OrgUser();
               profile.Name = xxuser.CNName;//名字
                //profile.DepartId = Entity.OA_DEPART.depart01;//部门id
                //profile.DepartName = Entity.OA_DEPART.depart02;//部门名称
                profile.RoleId = xxuser.RoleId.HasValue?xxuser.RoleId.Value:0;
                if (xxuser != null)
                {
                    profile.DistrictId = xxuser.AdminUser.DistrictCode;
                    profile.ParentDistrictId = xxuser.AdminUser.hW_District.ParentDistrictCode;
                }
                profile.AdminUser = xxuser.AdminUser == null ? new HW_Manger_Admin_User() : xxuser.AdminUser;
                profile.OrgUser = xxuser.OrgUser == null ? new HW_OrgUser() : xxuser.OrgUser;
                profile.SchoolUser = xxuser.SchoolUser==null?new HW_School_User():xxuser.SchoolUser;
                profile.Save();
                Page.Response.Redirect("HealthMain.aspx"); 
            }
        }
    }
}